/**   
 * @Title: TitleMenuGridAdapter.java 
 * @Package com.esun.rabbit2.viewer.mainact.hemaicenteragp 
 * @Description: 顶部菜单gridview的adapter 
 * @author: City Jiangsy@500wan.com   
 * @date: 2011-11-29 上午11:23:22  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.viewer.mainact.titlemenu;

import java.util.ArrayList;
import java.util.Hashtable;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;

import com.esun.config.Config;
import com.esun.ui.R;

/**
 * @ClassName: TitleMenuGridAdapter
 * @Description: 顶部菜单gridview的adapter
 * @author: City Jiangsy@500wan.com
 * @date: 2011-11-29 上午11:23:22
 * 
 */
public class TitleMenuGridAdapter extends BaseAdapter {
	private ArrayList<Hashtable<String, Object>> list;
	private LayoutInflater layoutInflater;

	public TitleMenuGridAdapter(Context context, ArrayList<Hashtable<String, Object>> list) {
		this.list = list;
		this.layoutInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		// if (convertView == null) {
		convertView = layoutInflater.inflate(R.layout.title_menu_btn_item, null);
		// }
		ImageButton btn = (ImageButton) convertView.findViewById(R.id.titlemenubtnitem_btn);
		btn.setImageResource((Integer) list.get(position).get(Config.BG_RESOURCE));
		btn.setOnClickListener((OnClickListener) list.get(position).get(Config.CURRENT_LISTENER));
		return convertView;
	}

}
